package com.wanmait.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wanmait.community.validation.household.InsertGroup;
import com.wanmait.community.validation.household.LoginGroup;
import com.wanmait.community.validation.household.UpdateGroup;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;

/**
 * 用户表
 */
@Data
@Accessors(chain = true)
@TableName(value = "`user`")
public class User {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 姓名
     */
    @TableField(value = "user_name")
    @NotEmpty(message = "用户名不能为空")
    private String userName;

    /**
     * 密码
     */
    @TableField(value = "user_pass")
    @NotEmpty(message = "密码不能为空")
    private String userPass;

    /**
     * 出生日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @TableField(value = "birthday")
    @NotNull(message = "出生日期不能为空",groups = {InsertGroup.class})
    @Past(message = "日期不能晚于当前时间",groups = {InsertGroup.class})
    private Date birthday;

    /**
     * 性别
     */
    @TableField(value = "gender")
    @NotEmpty(message = "性别不能为空",groups = {InsertGroup.class})
    @Pattern(regexp = "^[男女]$",message = "性别只能是男或女",groups = {InsertGroup.class})
    private String gender;

    /**
     * 邮箱
     */
    @TableField(value = "email")
    @Email(message = "邮箱格式不正确",groups = {InsertGroup.class, UpdateGroup.class})
    private String email;

    /**
     * 电话
     */
    @TableField(value = "phone")
    @NotEmpty(message = "电话不能为空",groups = {InsertGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^1[3-9]\\d{9}$",message = "手机号码格式不正确",groups = {InsertGroup.class, UpdateGroup.class})
    private String phone;

    /**
     * 身份证号
     */
    @TableField(value = "in_num")
    @NotEmpty(message = "身份证号不能为空",groups = {InsertGroup.class})
    @Pattern(regexp = "^\\d{17}[\\dXx]$",message = "身份证号不正确",groups = {InsertGroup.class})
    private String inNum;

    /**
     * 学历id
     */
    @TableField(value = "education_id")
    @NotNull(message = "学历不能为空",groups = {InsertGroup.class, UpdateGroup.class})
    private Integer educationId;


    /**
     * 是否停用，1正常0停用
     */
    @TableField(value = "stop")
    private Boolean stop;

    /**
     * 身份证照片正面
     */
    @TableField(value = "photo_right")
    private String photoRight;

    /**
     * 身份证照片反面
     */
    @TableField(value = "photo_back")
    private String photoBack;
    /**
     * 最后登录ip
     */
    @TableField(value = "login_ip")
    @NotEmpty(message = "登录IP地址不能为空",groups = {LoginGroup.class})
    private String loginIp;

    /**
     * 创建用户id
     */
    @TableField(value = "creat_by")
    private Integer creatBy;

    /**
     * 创建时间
     */
    @TableField(value = "creat_time")
    private Date creatTime;

    /**
     * 更新用户id
     */
    @TableField(value = "update_by")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 删除标志1未删除0删除
     */
    @TableField(value = "`enable`")
    private Boolean enable;

    @TableField(exist = false)
    private Integer roomCount;

    @TableField(exist = false)
    private Integer carCount;

    /**
     * 身份名称
     */
    @TableField(value = "`identity`")
    @NotEmpty(message = "请输入该用户的身份",groups = {InsertGroup.class})
    private String identity;
}